package com.linedata.acq.metier.norme.fmb;

import oracle.forms.jdapi.Block;
import oracle.forms.jdapi.FormModule;
import oracle.forms.jdapi.JdapiIterator;

public class GBLK_FMB {

	private FormModule	fmb;

	public GBLK_FMB(FormModule fmb) {
		this.fmb = fmb;
	}

	private String	error	= "";

	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error += error;
	}

	/**
	 * EKFR007_1 :: Le nom des blocks basés est le nom de la table sur laquelle
	 * le block est basé
	 * 
	 * @param fmb
	 */
	public void nomBlockBase() {

		for (JdapiIterator blocks = fmb.getBlocks(); blocks.hasNext();) {

			Block block = (Block) blocks.next();
			if (block.getQueryDataSourceName().trim().equals(" ") && !block.getQueryDataSourceName().contains(",")
					&& !block.getName().toUpperCase().equals(block.getQueryDataSourceName().toUpperCase())) {

				this.setError("\tEKFR007_1 : " + block.getName() + "\n");
			}
		}
	}

	@Override
	public String toString() {
		return this.getError();
	}
}
